#include "db_manager.h"
#include "../config/conf_manager.h"
DBManager *DBManager::dbManager_ = new DBManager;

bool DBManager::init()
{
    auto conf = ConfManager::getInstance()->getConfMap();
    ip_ = conf["dbip"];
    port_ = conf["dbport"];
    user_ = conf["dbuser"];
    pwd_ = conf["dbpwd"];
    dbQuery = new DBQuery;
    return dbQuery->init(ip_,port_,user_,pwd_);
}

QList<DeptNode> DBManager::selectDeptQuery(QString sql)
{
    return dbQuery->selectDeptQuery(sql);
}

QMap<QString, QString> DBManager::selectLoginQuery(QString sql)
{
    return dbQuery->selectLoginQuery(sql);
}

QList<QList<QString> > DBManager::select(QString sql)
{
    return dbQuery->select(sql);
}

QSqlDatabase DBManager::getDataDBClient()
{
    return dbQuery->getDataDBClient();
}

DBManager::DBManager(QObject *parent) : QObject(parent)
{

}
